1669C - OddEven Increments - CodeForces Solution


greedy greedy implementation math *800

Please click on ads to support us..

C++ Code:

// codex by priyanshu
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast()                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define loop(i, ini, n) for (ll i = ini; i < (ll)n; i++)
#define pool(i, n, last) for (ll i = (ll)n; i > last; i--)
#define all(x) x.begin(), x.end()
#define tc     \
    ll tt;     \
    cin >> tt; \
    while (tt--)
#define gcd __gcd
#define inf 1e18
#define ninf INT_MIN
#define pb push_back
#define po pop_back
#define sz size()
#define ed end()
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define vl vector<ll>
#define vll vector<vector<ll>>
#define pl pair<ll, ll>
#define ml map<ll, ll>
#define sl set<ll>
#define ql queue<ll>
const int N = 1000001;
#define pi 3.1415926536
ll mod = 32768;

void solve()
{
    ll n;
    cin>>n;
     vl v(n);
     ll sum=0;
     loop(i,0,n) cin>>v[i], sum+=v[i];
    
    sl s1, s2;
    for(int i=0; i<n; i+=2){
        s1.insert(v[i]%2);
    }
    for(int i=1; i<n; i+=2){
        s2.insert(v[i]%2);
    }

    if(s1.size()==1 && s2.size()==1) cout<<"YES\n";
    else cout<<"NO\n";
}

int main()
{
    fast();
    tc
    {
        solve();
    }
}


Comments

Submit
0 Comments
More Questions

318A - Even Odds
550B - Preparing Olympiad
939B - Hamster Farm
732A - Buy a Shovel
1220C - Substring Game in the Lesson
452A - Eevee
1647B - Madoka and the Elegant Gift
1408A - Circle Coloring
766B - Mahmoud and a Triangle
1618C - Paint the Array
469A - I Wanna Be the Guy
1294A - Collecting Coins
1227A - Math Problem
349A - Cinema Line
47A - Triangular numbers
1516B - AGAGA XOOORRR
1515A - Phoenix and Gold
1515B - Phoenix and Puzzle
155A - I_love_username
49A - Sleuth
1541A - Pretty Permutations
1632C - Strange Test
673A - Bear and Game
276A - Lunch Rush
1205A - Almost Equal
1020B - Badge
1353A - Most Unstable Array
770A - New Password
1646B - Quality vs Quantity
80A - Panoramix's Prediction